import React from 'react'
import ReactDom from 'react-dom'

import {BrowserRouter as Router, Switch, Route,Redirect, Link} from 'react-router-dom'
import Home from 'pages/home/index.jsx'
import Login from 'pages/login/index.jsx'
import Layout from 'components/layout/layout.jsx'
import ErrorPage from 'pages/error/index.jsx'
import UserList from 'pages/userList/index.jsx'


class App extends React.Component{
  render () {
    return (
      <Router>
        <Switch>
          <Route path="/login" component={Login} />
          <Route path="/" render={(props)=>(
            <Layout>
              <Switch>
                <Route exact path="/" component={Home} />
                <Route path="/product" component={Home} />
                <Route path="/product-category" component={Home} />
                <Route path="/order" component={Home} />
                <Route path="/user/index" component={UserList} />
                <Redirect exact from="/user" to="/user/index" />
                <Route component={ErrorPage} />
              </Switch>
            </Layout>
          )} />
        </Switch>
      </Router>
    ) 
  }
}

ReactDom.render(
  <App />
  ,
  document.getElementById('root')
)